﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Model;
using Intorise.Common;

namespace TestWindowsFormsApplication.Validator
{
    public class NormalValidator : IValidate
    {
        public Model.ValidateResutlEnum Validate(Model.Country country, string zip, string state, string city, System.Data.DataRow row, Model.FreightInfo info)
        {
            if (country == null || info.CountryModel == null)
            {
                return ValidateResutlEnum.Incorrect;
            }
            else
            {
                if (info.ResultText.Contains(country.NameCN) || info.ResultText.Contains(country.NameEN) || info.CountryModel.ID == country.ID)
                {
                    //核对邮编
                    if (!info.ResultText.Contains(zip) && (!info.ResultText.Contains(city) || !info.ResultText.Contains(state)))//邮编，城市，州都不匹配
                    {
                        return ValidateResutlEnum.Indeterminacy;
                    }
                }
                else//国家不对
                {
                    return ValidateResutlEnum.Incorrect;
                }
            }
            return ValidateResutlEnum.Correct;
        }
    }
}
